package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RecruitmentResume;
import com.ruoyi.system.service.IRecruitmentResumeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招聘-简历管理Controller
 *
 * @author ruoyi
 * @date 2022-11-05
 */
@Controller
@RequestMapping("/system/recRes")
public class RecruitmentResumeController extends BaseController
{
    private String prefix = "system/recRes";

    @Autowired
    private IRecruitmentResumeService recruitmentResumeService;

    @RequiresPermissions("system:recRes:view")
    @GetMapping()
    public String resume()
    {
        return prefix + "/recRes";
    }

    /**
     * 查询招聘-简历管理列表
     */
    @RequiresPermissions("system:recRes:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecruitmentResume recruitmentResume)
    {
        startPage();
        List<RecruitmentResume> list = recruitmentResumeService.selectRecruitmentResumeList(recruitmentResume);
        return getDataTable(list);
    }

    /**
     * 导出招聘-简历管理列表
     */
    @RequiresPermissions("system:recRes:export")
    @Log(title = "招聘-简历管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecruitmentResume recruitmentResume)
    {
        List<RecruitmentResume> list = recruitmentResumeService.selectRecruitmentResumeList(recruitmentResume);
        ExcelUtil<RecruitmentResume> util = new ExcelUtil<RecruitmentResume>(RecruitmentResume.class);
        return util.exportExcel(list, "招聘-简历管理数据");
    }

    /**
     * 新增招聘-简历管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存招聘-简历管理
     */
    @RequiresPermissions("system:recRes:add")
    @Log(title = "招聘-简历管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecruitmentResume recruitmentResume)
    {
        return toAjax(recruitmentResumeService.insertRecruitmentResume(recruitmentResume));
    }

    /**
     * 修改招聘-简历管理
     */
    @RequiresPermissions("system:recRes:edit")
    @GetMapping("/edit/{recResId}")
    public String edit(@PathVariable("recResId") Long recResId, ModelMap mmap)
    {
        RecruitmentResume recruitmentResume = recruitmentResumeService.selectRecruitmentResumeByRecResId(recResId);
        mmap.put("recruitmentResume", recruitmentResume);
        return prefix + "/edit";
    }

    /**
     * 修改保存招聘-简历管理
     */
    @RequiresPermissions("system:recRes:edit")
    @Log(title = "招聘-简历管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecruitmentResume recruitmentResume)
    {
        return toAjax(recruitmentResumeService.updateRecruitmentResume(recruitmentResume));
    }

    /**
     * 删除招聘-简历管理
     */
    @RequiresPermissions("system:recRes:remove")
    @Log(title = "招聘-简历管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recruitmentResumeService.deleteRecruitmentResumeByRecResIds(ids));
    }
}
